#include<bits/stdc++.h>
using namespace std;
int dd[100005],aa[100005],vv[100005],c[100005],cs[100005],n,m,l,uv,ans1,ans2;
double csl[100005],csr[100005];
int check(){
    int i;
    for(i=1;i<=n;i++){
        if(aa[i]!=0){
            break;
        }
    }
    if(i==n+1) return 1;
    for(i=1;i<=n;i++){
        if(aa[i]<=0){
            break;
        }
    }
    if(i==n+1) return 2;
    for(i=1;i<=n;i++){
        if(aa[i]>=0){
            break;
        }
    }
    if(i==n+1) return 3;
    return 0;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        ans1=0;ans2=0;
        cin>>n>>m>>l>>uv;
        for(int i=1;i<=n;i++){
            cin>>dd[i]>>vv[i]>>aa[i];
        }
        for(int i=1;i<=m;i++){
            cin>>c[i];
        }
        int f=check();
        if(f==1){
            for(int i=1;i<=n;i++){
                int d=dd[i],v=vv[i],a=aa[i];
                if(v>uv){
                    if(c[m]>=d){
                        ans1++;
                    }
                }
            }
            if(ans1==0) cout<<ans1<<' '<<m<<endl;
            else cout<<ans1<<' '<<m-1<<endl;
        }
        if(f==2){
            for(int i=1;i<=n;i++){
                int d=dd[i],v=vv[i],a=aa[i];
                double s=(uv*uv)-(v*v*1.0);
                s=s/2/(a*1.0);
                s=s+d*1.0;
                if(c[m]*1.0>s){
                    ans1++;
                }
            }
            if(ans1==0) cout<<ans1<<' '<<m<<endl;
            else cout<<ans1<<' '<<m-1<<endl;
        }
    }
    return 0;
}
